<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增sys_meet_manage')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-manage-add">
            <h4 class="form-header h4">sys_meet_manage信息</h4>
            <div class="form-group">    
                <label class="col-sm-3 control-label">会议编号：</label>
                <div class="col-sm-8">
                    <input name="id" class="form-control" type="text" disabled>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">紧急程度</label>
                <div class="col-sm-8">
<!--                    <input name="urgent" class="form-control" type="text">-->
                    <select name="urgent" class="form-control">
                        <option value="普通">普通</option>
                        <option value="略紧急">略紧急</option>
                        <option value="紧急">紧急</option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">地点：</label>
                <div class="col-sm-8">
<!--                    <input name="local" class="form-control" type="text">-->
                    <select name="local" id="local" class="form-control" >
                        <option th:each="item,info:${meet}" th:object="${item}" th:value="*{id}">
                            <span th:text="*{name}"></span>
                        </option>
                    </select>
                </div>
            </div>
            <input name="deptId" type="hidden" id="treeId"/>
            <div class="form-group">    
                <label class="col-sm-3 control-label">部门：</label>
                <div class="col-sm-8">
<!--                    <input name="deptId" class="form-control" type="text">-->
                    <input name="emailDept" onclick="selectDeptTree()" id="treeName" type="text" placeholder="请选择归属部门" class="form-control">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">主持人：</label>
                <div class="col-sm-8">
<!--                    <input name="hostId" class="form-control" type="text">-->
                    <select name="hostId" id="hostId" class="form-control" >
                        <option th:each="item,info:${users}" th:object="${item}" th:value="*{userId}">
                            <span th:text="*{userName}"></span>
                        </option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">开始时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="beginTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">结束时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="endTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">与会人员：</label>
                <div class="col-sm-8">
<!--                    <input name="joinId" class="form-control" type="text">-->
                    <select name="joinId" id="joinId" class="form-control" >
                        <option th:each="item,info:${users}" th:object="${item}" th:value="*{userId}">
                            <span th:text="*{userName}"></span>
                        </option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">分享人员：</label>
                <div class="col-sm-8">
<!--                    <input name="shareId" class="form-control" type="text">-->
                    <select name="shareId" id="shareId" class="form-control" >
                        <option th:each="item,info:${users}" th:object="${item}" th:value="*{userId}">
                            <span th:text="*{userName}"></span>
                        </option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">内容：</label>
                <div class="col-sm-8">
                    <textarea name="text" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">会议名称：</label>
                <div class="col-sm-8">
                    <input name="name" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">会议类型：</label>
                <div class="col-sm-8">
<!--                    <input name="state" class="form-control" type="text">-->
                    <select name="state" class="form-control" >
                        <option value="0">会议</option>
                        <option value="1">培训</option>
                        <option value="2">其他</option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">创建人：</label>
                <div class="col-sm-8">
<!--                    <input name="createId" class="form-control" type="text">-->
                    <input name="createId" class="form-control" th:value="${user.userId}"  type="hidden">
                    <span th:text="${user.userName}"></span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">创建时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="createName" class="form-control createdTime" disabled placeholder="自动获取当前时间" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group" style="visibility: hidden">
                <label class="col-sm-3 control-label">会议中：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="meeting" class="form-control" value="1"  type="text">
<!--                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
                    </div>
                </div>
            </div>
          <!--  <h4 class="form-header h4">sys_meet_room信息</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addRow()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delRow()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/manage"
        $("#form-manage-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            $('.createdTime').val(getNowTime())
            console.log( $('.createdTime').val())
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-manage-add').serialize());
            }
        }

        $("input[name='beginTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        //获取当前时间
        function getNowTime() {
            var date = new Date();
            //年 getFullYear()：四位数字返回年份
            var year = date.getFullYear();  //getFullYear()代替getYear()
            //月 getMonth()：0 ~ 11
            var month = date.getMonth() + 1;
            //日 getDate()：(1 ~ 31)
            var day = date.getDate();
            //时 getHours()：(0 ~ 23)
            var hour = date.getHours();
            //分 getMinutes()： (0 ~ 59)
            var minute = date.getMinutes();
            //秒 getSeconds()：(0 ~ 59)
            var second = date.getSeconds();

            var time = year + '-' + addZero(month) + '-' + addZero(day) + ' ' + addZero(hour) + ':' + addZero(minute) + ':' + addZero(second);
            return time;
        }


        //小于10的拼接上0字符串
        function addZero(s) {
            return s < 10 ? ('0' + s) : s;
        }

        $("input[name='endTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        /* 用户管理-新增-选择部门树 */
        function selectDeptTree() {
            var treeId = $("#treeId").val();
            var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
            var url = ctx + "system/user/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "380",
                url: url,
                callBack: doSubmit
            };
            console.log(deptId)
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var body = $.modal.getChildFrame(index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            $.modal.close(index);
        }
        $(function() {
            var options = {
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'name',
                    align: 'center',
                    title: '会议室名称',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysMeetroomList[%s].name' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'createName',
                    align: 'center',
                    title: '创建人',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysMeetroomList[%s].createName' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'createTime',
                    align: 'center',
                    title: '创建时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysMeetroomList[%s].createTime' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'local',
                    align: 'center',
                    title: '地址',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysMeetroomList[%s].local' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'people',
                    align: 'center',
                    title: '可容纳人数',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysMeetroomList[%s].people' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'area',
                    align: 'center',
                    title: '面积',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysMeetroomList[%s].area' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'tou',
                    align: 'center',
                    title: '投影 是否',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysMeetroomList[%s].tou' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'text',
                    align: 'center',
                    title: '备注',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysMeetroomList[%s].text' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'state',
                    align: 'center',
                    title: '状态 0-可用1-维护',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysMeetroomList[%s].state' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    field: 'type',
                    align: 'center',
                    title: '类型 0-普通1-其他',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysMeetroomList[%s].type' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var value = $.common.isNotEmpty(row.index) ? row.index : $.table.serialNumber(index);
                        return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delRowByIndex(\'' + value + '\')"><i class="fa fa-remove"></i>删除</a>';
                    }
                }]
            };
            $.table.init(options);
        });

        function addRow() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            var row = {
                index: $.table.serialNumber(count),
                name: "",
                createName: "",
                createTime: "",
                local: "",
                people: "",
                area: "",
                tou: "",
                text: "",
                state: "",
                type: "",
            }
            sub.addRow(row);
        }
    </script>
</body>
</html>